package handler

import (
	"go-file-perception-model/internal/service"
	"github.com/gin-gonic/gin"
)

// FileHandler 文件处理器 - 重构后的协调器
type FileHandler struct {
	indexHandler  *IndexHandler
	searchHandler *SearchHandler
	systemHandler *SystemHandler
	configHandler *ConfigHandler
}

// NewFileHandler 创建文件处理器实例
func NewFileHandler(fileService *service.FileService) *FileHandler {
	return &FileHandler{
		indexHandler:  NewIndexHandler(fileService),
		searchHandler: NewSearchHandler(fileService),
		systemHandler: NewSystemHandler(fileService),
		configHandler: NewConfigHandler(fileService),
	}
}

// 索引相关方法 - 委托给IndexHandler
func (h *FileHandler) IndexFiles(c *gin.Context) {
	h.indexHandler.IndexFiles(c)
}

func (h *FileHandler) GetIndexStatus(c *gin.Context) {
	h.indexHandler.GetIndexStatus(c)
}

func (h *FileHandler) GetIndexDirectories(c *gin.Context) {
	h.indexHandler.GetIndexDirectories(c)
}

func (h *FileHandler) AddIndexDirectory(c *gin.Context) {
	h.indexHandler.AddIndexDirectory(c)
}

func (h *FileHandler) RemoveIndexDirectory(c *gin.Context) {
	h.indexHandler.RemoveIndexDirectory(c)
}

func (h *FileHandler) UpdateIndexDirectoryStatus(c *gin.Context) {
	h.indexHandler.UpdateIndexDirectoryStatus(c)
}

func (h *FileHandler) SetIndexDirectories(c *gin.Context) {
	h.indexHandler.SetIndexDirectories(c)
}

func (h *FileHandler) ClearIndexChunks(c *gin.Context) {
	h.indexHandler.ClearIndexChunks(c)
}

func (h *FileHandler) ClearAllIndexChunks(c *gin.Context) {
	h.indexHandler.ClearAllIndexChunks(c)
}

// 搜索相关方法 - 委托给SearchHandler
func (h *FileHandler) SemanticSearch(c *gin.Context) {
	h.searchHandler.SemanticSearch(c)
}

func (h *FileHandler) RegexSearch(c *gin.Context) {
	h.searchHandler.RegexSearch(c)
}

// 系统相关方法 - 委托给SystemHandler
func (h *FileHandler) GetSystemStats(c *gin.Context) {
	h.systemHandler.GetSystemStats(c)
}

func (h *FileHandler) GetSystemStatus(c *gin.Context) {
	h.systemHandler.GetSystemStatus(c)
}

func (h *FileHandler) GetFileList(c *gin.Context) {
	h.systemHandler.GetFileList(c)
}

func (h *FileHandler) GetFileContent(c *gin.Context) {
	h.systemHandler.GetFileContent(c)
}

func (h *FileHandler) GetPointByID(c *gin.Context) {
	h.systemHandler.GetPointByID(c)
}

// 配置相关方法 - 委托给ConfigHandler
func (h *FileHandler) GetConfig(c *gin.Context) {
	h.configHandler.GetConfig(c)
}

func (h *FileHandler) SaveConfig(c *gin.Context) {
	h.configHandler.SaveConfig(c)
}